<template>
  <el-input v-model="_value" />
</template>

<script setup>
import { ref, defineProps, computed, defineEmits } from "vue";
import * as lodash from "lodash";
const props = defineProps({
  label: String,
});

const _input = ref(null);

const emit = defineEmits(["change"]);

let throttleFn = lodash.throttle(() => {
  emit("change", _input.value);
}, 500);

const _value = computed({
  get: () => {
    if (_input.value === null) {
      _input.value = props.label;
    }
    return _input.value;
  },

  set: (v) => {
    _input.value = v;
    throttleFn();
  },
});
</script>

<style>
</style>